import time
def bublesort(massiv,N):
    for i in range(N-1):
        for j in range(N-i-1):
            if massiv [j]>massiv[j+1]:
                massiv[j], massiv[j+1]=massiv[j+1],massiv[j]
def readlist(filename):
    file=open(filename, "r")
    data=file.readlines()
    return data

m1=readlist("m1_sorted.txt")
m2=readlist("m2_reverse.txt")
m3=readlist("m3_shuffle.txt")
razmer1=len(m1)
razmer2=len(m2)
razmer3=len(m3)
t_start=time.time()
bublesort(m1,razmer1)
t_finish=time.time()
print("m1_sorted.txt",round((t_finish-t_start)*1000),"millseconds")
razmer2=len(m2)
t_start=time.time()
bublesort(m2,razmer2)
t_finish=time.time()
print("m2_sorted.txt",round((t_finish-t_start)*1000),"millseconds")
razmer3=len(m3)
t_start=time.time()
bublesort(m3,razmer3)
t_finish=time.time()
print("m3_sorted.txt",round((t_finish-t_start)*1000),"millseconds")
            
